#include <cassert>
#include <ostream>
#include <sstream>
#include <string>

#include "Prey.h"
#include "State/Game/PreyStates.h"


Prey::Prey()
: BaseEntity()
, m_currentPredatorID(-1)
{
	m_stateMachine = new StateMachine<Prey>(this);
	m_stateMachine->ChangeCurrentState(PreyStateWander::GetInstance());
}


Prey::~Prey()
{
	delete m_stateMachine;
}

void Prey::Update()
{
	assert(m_stateMachine && "<Prey::Update()>: m_stateMachine == NULL");
	if (m_stateMachine)
	{
		m_stateMachine->Update();
	}
}

bool Prey::HandleMessage(const Message& message)
{
	assert(m_stateMachine && "<Prey::HandleMessage()>: m_stateMachine == NULL");

	if (m_stateMachine)
	{
		return m_stateMachine->HandleMessage(message);
	}

	return false;
}

std::string Prey::GetEnityName()
{
	std::ostringstream oss;
	oss << "Prey_" << ID();
	
	return oss.str();
}

StateMachine<Prey>* Prey::GetStateMachine() const
{
	return m_stateMachine;
}

AITypes::EntityID Prey::GetCurrentPredatorID() const
{
	return m_currentPredatorID;
}

void Prey::SetCurrentPredatorID(AITypes::EntityID id)
{
	m_currentPredatorID = id;
}
